﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace BLL
{
    public class StylePriceBLL
    {
        private readonly DAL.StylePriceDAL stylepricedal = new DAL.StylePriceDAL();
        /// <summary>
        /// 获取一个订单项的所有需要付款的样式和价格
        /// </summary>
        public DataTable getItemStylePrice(string orderitemid)
        {
            BLL.ItemStyleBLL itemstylebll = new BLL.ItemStyleBLL();
            DataTable dtItemStyle = itemstylebll.getItemStyle(orderitemid);
            string styleidlist = "";
            foreach (DataRow drItemStyle in dtItemStyle.Rows)
            {
                styleidlist += drItemStyle["valueID"].ToString() + ",";
            }
            styleidlist = (styleidlist == "") ? "" : styleidlist.Substring(0, styleidlist.Length - 1);
            return stylepricedal.getStylePrice("styleID in ("+styleidlist+")");
            
        }
        /// <summary>
        /// 根据styleID获取该style的price
        /// </summary>
        /// <param name="p"></param>
        public decimal getStylePrice(string styleid)
        {
            DataTable dt=stylepricedal.getStylePrice("styleID="+styleid);
            if (dt.Rows.Count > 0)
            {
                return decimal.Parse(dt.Rows[0]["stylePrice"].ToString());
            }
            else
            {
                return 0;  
            }
        }
        /// <summary>
        ///添加样式价格
        /// </summary>
        public void addPrice(Albon.Model.StylePrice styleprice)
        {
            stylepricedal.addPrice(styleprice);
        }

        
    }
}
